l = [1, 4, 2, 7, 3, 9, 8, 0]

def func(l):
    l = l[::-1]
    for i in range(len(l) - 1):
        for g in range(len(l) - 1 - i):
            if l[g] > l[g+1]:
                l[g], l[g+1] = l[g+1], l[g]

    return l

print(func(l))

# 方法2
def insert_sort(l):
    for i in range(1, len(l)):
        j = i - 1
        key = l[i]
        while j >= 0:
            if l[j] > key:
                l[j+1] = l[j]
                l[j] = key
            j -= 1
    return l

print(insert_sort(l))

